<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      v-for="item in listState"
      :key="item.id"
      :class="{ completed: item.isDone }"
    >
      <div class="view">
        <input
          class="toggle"
          type="checkbox"
          :id="item.id"
          v-model="item.isDone"
        />
        <label :for="item.id">{{ item.name }}</label>
        <button class="destroy" @click="remove(item.id)"></button>
      </div>
    </li>
  </ul>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters('ToDos', ['listState'])
  },
  methods: {
    remove(id) {
      this.$store.commit('ToDos/listRemove', id)
    }
  }
}
</script>
